"""
模拟键盘操作
send_keys(Keys.CONTROL,'a')           #全选（Ctrl+A）
send_keys(Keys.CONTROL,'c')           #复制（Ctrl+C）
send_keys(Keys.CONTROL,'x')           #剪切（Ctrl+X）
send_keys(Keys.CONTROL,'v')           #粘贴（Ctrl+V）
send_keys(Keys.ENTER)                 #回车键
send_keys(Keys.BACK_SPACE)            #删除键
send_keys(Keys.SPACE)                 #空格键
send_keys(Keys.TAB)                   #制表键
send_keys(Keys.ESCAPE)                #回退键
"""

import time
import selenium
from selenium.webdriver import chrome
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys

url = "D:/test/keys_selenium.html"

driver = selenium.webdriver.Chrome()
driver.maximize_window()
driver.implicitly_wait(10)

driver.get(url=url)

el = driver.find_element(By.ID,'A')
time.sleep(2)
el.send_keys(Keys.CONTROL,'a')
time.sleep(2)
el.send_keys(Keys.CONTROL,'x')
time.sleep(2)
el.send_keys(Keys.CONTROL,'v')
time.sleep(2)
el.send_keys(Keys.BACK_SPACE)

time.sleep(5)
driver.quit()
